package com.metaera.app.controller.presenter;

import com.metaera.app.controller.core.RequestPresenter;
import com.metaera.app.controller.view.core.INetworkRequestView;
import com.metaera.app.controller.view.core.IStatusView;
import com.metaera.app.data.DataRepository;
import com.metaera.app.data.model.SpecialDetailsResponse;
import com.metaera.app.data.rx.ResponseObserver;
import com.metaera.app.data.rx.SchedulersTransformer;

public class SpecialDetailsPresenter extends RequestPresenter<INetworkRequestView<SpecialDetailsResponse>> {

    private final IStatusView mStatusView;

    public SpecialDetailsPresenter(IStatusView statusView){
        mStatusView = statusView;
    }

    public void execute(int id){
        DataRepository.getInstance()
                .getSpecialDetails(id)
                .compose(SchedulersTransformer.transformer(mStatusView))
                .subscribe(new ResponseObserver<>(
                                this,
                                mView,
                                response -> mView.successful(response.getData())
                        )
                );
    }

}
